<template>
  <div class="role-promulgator" :class="{ 'bg-fff': apply_status == 0 }">
    <c-title :text="text"></c-title>

    <template v-if="apply_status !== 0 || apply_for_type == 5 || apply_for_type == 6 || apply_for_type == 7">
      <p class="tips">申请信息</p>

      <!-- 发布者申请  -->
      <van-cell-group v-if="apply_for_type == 1 || apply_for_type == 7">
        <van-field required v-model="realname" label="姓名" placeholder="请输入姓名" />
        <van-field required v-model="mobile" label="手机号" placeholder="请输入联系电话" />
        <van-field required v-model="age" label="年龄" placeholder="请输入年龄" />
        <van-field
          required
          readonly
          @click="addressShow = true"
          v-model="addressName"
          right-icon="arrow"
          label="位置"
          placeholder="请选择所在区域"
        />
        <van-field
          v-if="strShow"
          required
          readonly
          @click="streetShow_apply = true"
          :value="address_form.street"
          right-icon="arrow"
          label="街道"
          placeholder="请选择所在区域"
        />
        <div class="img-pane">
            <div class="img-name required">上传身份证国徽面</div>
            <yz_uploader v-model="id_card_reverse" :max_count="1" :isCustomStyle="true" :styles="{ padding: '0' }" @inputimg="input_reverse" :picture="picture1" >
              <div class="upload-box"><van-icon name="plus" class="plus-icon" /></div>
            </yz_uploader>
          </div>
          <div class="img-pane">
            <div class="img-name required">上传身份证人像面</div>
            <yz_uploader v-model="id_card_front" :max_count="1" :isCustomStyle="true" :styles="{ padding: '0' }" @inputimg="input_front"  :picture="picture2" >
              <div class="upload-box"><van-icon name="plus" class="plus-icon" /></div>
            </yz_uploader>
          </div>
      </van-cell-group>

      <!-- 技能师傅申请  -->
      <template v-if="apply_for_type == 2 || apply_for_type == 6">
        <van-cell-group>
          <div style="position: relative;">
            <van-field
              v-if="apply_for_type == 6"
              required
              v-model="member_realname"
              @input="input_handle"
              @focus="focus"
              label="会员"
              placeholder="请输入会员ID"
            ></van-field>
            <div class="search-tip" v-if="tips_list && tips_list.length !== 0">
              <div class="box">
                <div
                  class="flex-between"
                  style="padding: 0.625rem;"
                  v-for="(item, i) in tips_list"
                  :key="i"
                  @click="choose_handle(item)"
                >
                  <span>{{ item.nickname }}</span>
                  <div class="flex-between">
                    <van-image width="1.125rem" height="1.125rem" round :src="item.avatar_image" />
                    <span style="margin-left: 0.25rem;">ID:{{ item.uid }}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <van-field required v-model="realname" label="姓名" placeholder="请输入姓名" />
          <van-field required v-model="mobile" label="手机号" placeholder="请输入联系电话" />
          <van-field
            required
            :value="(radio == '1') ? '男' : (radio == '2') ? '女' : ''"
            readonly
            label="性别"
            right-icon="arrow"
            placeholder="请选择性别"
            @click="categoryShow = true"
          />
          <van-field v-model="age" label="年龄" placeholder="请输入年龄" />
          <template v-if="apply_for_type == 2">
            <van-field
              required
              readonly
              @click="addressShow = true"
              v-model="addressName"
              right-icon="arrow"
              label="师傅所在地"
              placeholder="请选择所在区域"
            />
            <van-field
              v-if="strShow"
              required
              readonly
              @click="streetShow_apply = true"
              v-model="address_form.street"
              right-icon="arrow"
              label="街道"
              placeholder="请选择所在区域"
            />
          </template>
          <!-- 区域代理 -->
          <template v-else>
            <van-field
              required
              readonly
              @click="show_serve_popup = true"
              :value="addressName"
              right-icon="arrow"
              label="师傅所在地"
              placeholder="请选择所在区域"
            />
            <van-field
              v-if="strShow"
              required
              readonly
              @click="streetShow = true"
              :value="address_form.street"
              right-icon="arrow"
              label="街道"
              placeholder="请选择所在区域"
            />
          </template>
          <van-field
            required
            readonly
            :value="locationTitle"
            @click="go_to_loaction"
            label="地理位置"
            placeholder="请选择所在位置"
          >
            <template #right-icon>
              <i class="iconfont icon-order_locate"></i>
            </template>
          </van-field>
        </van-cell-group>
        <div style="height: 0.5rem;"></div>
        <van-cell-group>
          <van-field v-model="native_place" label="籍贯" placeholder="请输入籍贯" />
          <van-field v-model="nation" label="民族" placeholder="请输入民族" />
          <van-field v-model="education" label="学历" placeholder="请输入学历" />
          <van-field v-model="stature" label="身高" placeholder="请输入身高" />
          <van-field v-model="weight" label="体重" placeholder="请输入体重" />
          <van-field v-model="introduce" label="简介" placeholder="请输入简介" />
        </van-cell-group>
        <div style="height: 0.5rem;"></div>
        <van-cell-group>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p >技能证书</p>
            <van-uploader
              preview-size="6.4rem"
              v-model="capability_certificate"
              :after-read="afterReadCertificate"
              max-count="1"
            >
              <div class="upload-elem"></div>
            </van-uploader>
          </div>
          <div class="img-pane">
            <div class="img-name required">上传身份证国徽面</div>
            <yz_uploader v-model="id_card_reverse" :max_count="1" :isCustomStyle="true" :styles="{ padding: '0' }" @inputimg="input_reverse"  :picture="picture1">
              <div class="upload-box"><van-icon name="plus" class="plus-icon" /></div>
            </yz_uploader>
          </div>
          <div class="img-pane">
            <div class="img-name required">上传身份证人像面</div>
            <yz_uploader v-model="id_card_front" :max_count="1" :isCustomStyle="true" :styles="{ padding: '0' }" @inputimg="input_front" :picture="picture2">
              <div class="upload-box"><van-icon name="plus" class="plus-icon" /></div>
            </yz_uploader>
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p>健康证件</p>
            <van-uploader
              preview-size="6.4rem"
              v-model="health_certificate"
              :after-read="afterReadHealth"
              max-count="1"
            >
              <div class="upload-elem"></div>
            </van-uploader>
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p class="required">个人照片</p>
            <van-uploader
              preview-size="6.4rem"
              v-model="shifu_image"
              :after-read="afterReadPhoto"
              max-count="1"
            >
              <div class="upload-elem"></div>
            </van-uploader>
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p  style="margin-bottom: 0.625rem;">短视频</p>
            <div style="display: flex;">
              <div class="uploader-video" v-show="video">
                <video
                  preload="metadata"
                  controlslist="nodownload"
                  width="100%"
                  height="100%"
                  custom-cache="false"
                  ref="video"
                  webkit-playsinline="true"
                  x5-video-player-type="h5"
                  playsinline
                  x5-playsinline
                  x5-video-orientation="portrait"
                  x5-video-player-fullscreen
                  autoplay
                  controls
                  :src="videoUrl"
                  id="video"
                  muted
                  v-show="videoUrl"
                  @loadeddata="onloadeddata"
                  style="background: #fff;"
                >
                  <source :src="videoUrl" type="video/ogg" />
                  <source :src="videoUrl" type="video/mp4" />
                  <source :src="videoUrl" type="video/webm" />你的浏览器不支持video标签！
                </video>
                <i
                  @click.stop="removeImg"
                  v-show="!id && videoUrl"
                  class="iconfont icon-guanbi deletaIcon"
                ></i>
              </div>

              <van-uploader
                v-show="!video"
                max-count="1"
                preview-size="6.4rem"
                :preview-image="false"
                accept="video/*"
                :before-read="beforeReadVideo"
              >
                <div class="upload-elem" style="margin-top: 0;"></div>
              </van-uploader>
            </div>
          </div>
        </van-cell-group>
      </template>

      <!-- 企业申请  -->
      <template v-if="apply_for_type == 3">
        <van-cell-group>
          <van-field required v-model="realname" label="企业名称" placeholder="请输入企业名称" />
          <div class="img-pane">
            <div class="img-name required">营业执照</div>
            <yz_uploader v-model="corp_license" :max_count="1" :isCustomStyle="true" :styles="{ padding: '0' }" @inputimg="input_license" >
              <div class="upload-box"><van-icon name="plus" class="plus-icon" /></div>
            </yz_uploader>
          </div>
          <van-field required v-model="corp_business_scope" label="经营范围" placeholder="请输入经营范围" />
        </van-cell-group>
        <div style="height: 0.5rem;"></div>
        <van-cell-group>
          <van-field required v-model="corp_legal_person" label="法人" placeholder="请输入法人" />
          <van-field required v-model="corp_contact" label="联系人" placeholder="请输入联系人" />
          <van-field required v-model="mobile" label="联系方式" placeholder="请输入联系方式" />
          <div class="img-pane">
            <div class="img-name required">上传身份证国徽面</div>
            <yz_uploader v-model="id_card_reverse" :max_count="1" :isCustomStyle="true" :styles="{ padding: '0' }" @inputimg="input_reverse" >
              <div class="upload-box"><van-icon name="plus" class="plus-icon" /></div>
            </yz_uploader>
          </div>

          <div class="img-pane">
            <div class="img-name required">上传身份证人像面</div>
            <yz_uploader v-model="id_card_front" :max_count="1" :isCustomStyle="true" :styles="{ padding: '0' }" @inputimg="input_front" >
              <div class="upload-box"><van-icon name="plus" class="plus-icon" /></div>
            </yz_uploader>
          </div>
        </van-cell-group>
        <div style="height: 0.5rem;"></div>
        <van-cell-group>
          <van-field required v-model="corp_address" label="企业地址" placeholder="请输入企业地址" />
          <van-field required v-model="introduce" label="简介" placeholder="请输入简介" />
          <div
            class="flex-column-start company"
          >
            <p class="required">公司照片</p>
            <van-uploader
              preview-size="6.4rem"
              v-model="corp_image"
              :after-read="afterReadCorpImage"
            >
              <div class="upload-elem"></div>
            </van-uploader>
          </div>
        </van-cell-group>
      </template>

      <!-- 技能师傅详情 -->
      <template v-if="apply_for_type == 4 || apply_for_type == 5">
        <van-cell-group>
          <van-field
            v-if="apply_for_type == 5"
            required
            :value="member_realname"
            label="会员"
            readonly
          />
          <van-field required :value="realname" label="姓名" readonly />
          <van-field required :value="mobile" label="手机号" readonly />
          <van-field
            required
            :value="(radio == '1') ? '男' : (radio == '2') ? '女' : ''"
            readonly
            label="性别"
          />
          <van-field :value="age" readonly label="年龄" />
          <van-field required readonly :value="addressName" label="师傅所在地" />
          <van-field required readonly :value="address_form.street" label="街道" />
          <van-field required readonly :value="locationTitle" label="地理位置" />
        </van-cell-group>

        <div style="height: 0.5rem;"></div>
        <van-cell-group>
          <van-field readonly :value="native_place" label="籍贯" />
          <van-field readonly :value="nation" label="民族" />
          <van-field readonly :value="education" label="学历" />
          <van-field readonly :value="stature" label="身高" />
          <van-field readonly :value="weight" label="体重" />
          <van-field readonly :value="introduce" label="简介" />
        </van-cell-group>
        <div style="height: 0.5rem;"></div>
        <van-cell-group>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p >技能证书</p>
            <van-uploader
              preview-size="6.4rem"
              :readonly="true"
              v-model="capability_certificate"
              max-count="1"
              :deletable="false"
            />
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p class="required">上传身份证国徽面</p>
            <van-uploader
              preview-size="6.4rem"
              max-count="1"
              v-model="id_card_reverse"
              :deletable="false"
            />
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p class="required">上传身份证人像面</p>
            <van-uploader
              preview-size="6.4rem"
              max-count="1"
              v-model="id_card_front"
              :deletable="false"
            />
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p>健康证件</p>
            <van-uploader
              preview-size="6.4rem"
              max-count="1"
              v-model="health_certificate"
              :deletable="false"
            />
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p class="required">个人照片</p>
            <van-uploader
              preview-size="6.4rem"
              max-count="1"
              v-model="shifu_image"
              :deletable="false"
            />
          </div>
          <div
            class="flex-column-start"
            style="padding-top: 1.25rem; padding-left: 0.8125rem; padding-bottom: 1.25rem;"
          >
            <p  style="margin-bottom: 0.625rem;">短视频</p>
            <div style="display: flex;">
              <div
                class="uploader-video"
                style="height: 6.4375rem; width: 6.4375rem; margin-right: 0.875rem;"
                v-show="videoUrl != ''"
              >
                <video
                  preload="metadata"
                  controlslist="nodownload"
                  width="100%"
                  height="100%"
                  custom-cache="false"
                  ref="video"
                  webkit-playsinline="true"
                  x5-video-player-type="h5"
                  playsinline
                  x5-playsinline
                  x5-video-orientation="portrait"
                  x5-video-player-fullscreen
                  autoplay
                  controls
                  :src="videoUrl"
                  id="video"
                  muted
                  v-show="videoUrl"
                  @loadeddata="onloadeddata"
                  style="background: #fff;"
                >
                  <source :src="videoUrl" type="video/ogg" />
                  <source :src="videoUrl" type="video/mp4" />
                  <source :src="videoUrl" type="video/webm" />你的浏览器不支持video标签！
                </video>
              </div>
            </div>
          </div>
        </van-cell-group>
      </template>

      <div class="btn" :class="{right:reason}"
        v-if="can_apply == 99 || apply_for_type == 2 || apply_for_type == 6 || apply_for_type == 1 ||apply_for_type == 3 || apply_for_type == 7 "
      >
        <van-button v-if="reason && apply_status == -1 "  round color="#4978F8" @click="republish">重新发布</van-button>
        <van-button v-else block round color="#4978F8" @click="submit">提交</van-button>
      </div>
    </template>
    <div v-else style="margin-top: 5.4688rem;">
      <van-image
        width="5.125rem"
        height="5.125rem"
        src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/anytime_service/icon_ waiting.png"
      />
      <p style="margin-top: 0.5938rem;">申请提交成功，等待平台审核</p>
    </div>

    <div @click="gotoRecord" class="record" v-if="apply_for_type!==3">申请记录</div>

    <div v-if="reason && apply_status == -1 ">
      <div class="reject" >
        <div  class="tip">驳回原因</div>
        <div class="reject-content">{{reason}}</div>
      </div>
      <div style="height: 0.9375rem;"></div>
    </div>

    <!-- 服务站选择器 s -->
    <van-popup v-model="show_serve_popup" round position="bottom">
      <van-area title="选择服务站" :area-list="columns" @confirm="serve_confirm" @cancel="serve_cancel" />
    </van-popup>
    <van-popup v-model="streetShow" round position="bottom" :style="{ height: '40%' }">
      <van-picker
        title="选择街道"
        show-toolbar
        :columns="stree_columns"
        @confirm="stree_confirm"
        @cancel="stree_cancel"
      />
    </van-popup>
    <!-- 服务站择器 end -->

    <!-- 省市区地址选择器 s -->
    <yd-cityselect
      style="height: 80%; z-index: 1000000;"
      v-model="addressShow"
      :callback="addressCallback"
      :items="district"
    ></yd-cityselect>
    <!-- 省市区地址选择器 end -->

    <!-- 街道选择器 s -->
    <van-popup v-model="streetShow_apply" round position="bottom" :style="{ height: '80%' }">
      <div class="m-dialog1">
        <van-nav-bar title="选择街道" class="pcStyle_ydT">
          <template #left>
            <span>
              <van-icon
                name="arrow-left"
                size="18"
                @click.native="streetShow_apply = false"
                color="#333"
              />
            </span>
          </template>
        </van-nav-bar>
        <van-cell
          :border="false"
          center
          is-link
          v-for="(item, i) in districtVal"
          :key="i"
          @click.native="streetConfirm(item)"
          title-style="text-align:left"
        >
          <span slot="title">{{ item.areaname }}</span>
        </van-cell>
      </div>
    </van-popup>
    <!-- 街道选择器 end -->

    <!-- 性别选择器start -->
    <van-popup v-model="categoryShow" round position="bottom">
      <div class="catrogey-popuop">
        <div class="flex-between p32-40">
          <span @click="categoryShow = false" class="fz24 c999">取消</span>
          <span class="fz30 fw-bold">性别</span>
          <span @click="categoryShow = false" class="fz24">确认</span>
        </div>
        <van-radio-group v-model="radio">
          <van-cell-group>
            <van-cell title="男" clickable @click="radio = '1'">
              <template #right-icon>
                <van-radio name="1"></van-radio>
              </template>
            </van-cell>
            <van-cell title="女" clickable @click="radio = '2'">
              <template #right-icon>
                <van-radio name="2"></van-radio>
              </template>
            </van-cell>
          </van-cell-group>
        </van-radio-group>
      </div>
    </van-popup>
  </div>
</template>

<script>
import role_apply_controller from "./role_apply_controller";
export default role_apply_controller;
</script>

<style >
.imgUploader {
  background-color: white !important;
  padding: 0 !important;
}

.imgUploader .photoBox {
  width: 6.5rem !important;
  height: 6.5rem !important;
}

.imgUploader .van-uploader {
  width: 6.5rem !important;
  height: 6.5rem !important;
  background: white !important;
}

.imgUploader .photoBox i {
  top: -0.6rem !important;
  right: -0.6rem !important;
}
</style>
<style scoped lang="scss">
.right {
  text-align: right;
}

.tip {
  font-size: 1.5rem;
  padding: 1.1563rem 0.6563rem;
  text-align: left;
  font-weight: 500;
}

.reject-content {
  padding: 1.125rem;
  background: #fff;
  color: black;
  word-break: break-all;
  text-align: left;
  margin-bottom: 1rem;
}

.record {
  position: fixed;
  bottom: 5rem;
  right: 0.75rem;
  width: 4rem;
  height: 4rem;
  line-height: 4rem;
  background: #4978f8;
  border-radius: 100px;
  color: #fff;
  text-align: center;
}

.img-pane {
  text-align: left;
  padding: 0 0.4rem;
  margin: 0.75rem 0 1rem 0;

  .img-name {
    font-size: 0.8rem;
    font-weight: 400;
    color: #646566;
    margin-bottom: 0.75rem;
    margin-left: 0.5rem;
  }

  .upload-box-border {
    border: 0.05rem dotted #dbdbdb;
  }

  .img-pic {
    width: 100%;
    height: 100%;
    margin: 0;
    width: 6.5rem;
    height: 6.5rem;
  }

  .upload-box {
    width: 6.5rem;
    height: 6.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    // .plus-icon {
    //   font-size: 1.2rem;
    //   color: #999999;
    // }
  }
}

.company {
  padding-top: 1.25rem;
  padding-left: 0.8125rem;
  padding-bottom: 1.25rem;
}

.upload-box {
  width: 6.5rem;
  height: 6.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  // .plus-icon {
  //   font-size: 1.2rem;
  //   color: #999999;
  // }
}

::v-deep .company .van-uploader__wrapper {
  display: flex;
  flex-wrap: wrap;
}

::v-deep .catrogey-popuop .van-cell__title {
  text-align: left;
}

::v-deep .catrogey-popuop .van-radio__icon--checked .van-icon {
  color: #1989fa;
  background-color: unset;
  border-color: unset;
}

::v-deep .catrogey-popuop .van-icon {
  border: unset;
}

.bg-fff {
  background: #fff;
}

.role-promulgator {
  position: relative;
  padding-bottom: 6.25rem;
  min-height: 100vh;

  .uploader-video {
    height: 6.4375rem;
    width: 6.4375rem;
    margin-right: 0.875rem;
    position: relative;
  }

  .deletaIcon {
    font-size: 0.25rem;
    padding: 0.25rem;
    box-sizing: border-box;
    background: #999;
    color: #fff;
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    border-radius: 100%;
  }

  .mb-31 {
    margin-bottom: 0.9688rem;
  }

  .search-tip {
    position: absolute;
    left: 24%;
    top: 87%;
    width: 14rem;
    height: 8rem;
    background: #fff;
    border-radius: 0.125rem 0.125rem 0.125rem 0.125rem;
    border: 1px solid #ececec;
    margin: 0.3125rem auto;
    z-index: 10;

    .box {
      height: 100%;
      overflow-y: scroll;
      background: #fff;
      z-index: 100;
    }

    &::after {
      content: "";
      width: 0;
      height: 0;
      border: 12px solid;
      position: absolute;
      top: -23px;
      left: 20px;
      border-color: #fff transparent transparent transparent;
      transform: rotate(180deg);
    }

    &::before {
      content: "";
      width: 0;
      height: 0;
      border: 12px solid;
      position: absolute;
      top: -25px;
      left: 20px;
      border-color: #ececec transparent transparent transparent;
      transform: rotate(180deg);
    }
  }

  .flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .p32-40 {
    padding: 1rem 1.25rem;
  }

  .fw-bold {
    font-weight: bold;
  }

  .fz24 {
    font-size: 0.85rem;
  }

  .c999 {
    color: #999;
  }

  .btn {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 0.625rem 0.75rem;
  }

  .upload-elem {
    position: relative;
    margin-top: 0.875rem;
    width: 6.4375rem;
    height: 6.4375rem;
    border: 2px dotted #dbdbdb;

    &::after {
      position: absolute;
      content: "+";
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      font-size: 1.5625rem;
      color: #999;
    }
  }

  .flex-column-start {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .required {
    position: relative;
    text-align: left;

    &::before {
      position: absolute;
      left: -0.4063rem;
      color: #ee0a24;
      font-size: 14px;
      content: '*';
    }
  }

  .tips {
    text-align: left;
    font-size: 1rem;
    padding: 1.1563rem 0.6563rem;
  }
}
</style>
